package dog.gui;

import java.awt.Color;
import java.awt.Component;

import javax.swing.*;

import containers.Room;

public class RoomCellRenderer implements ListCellRenderer
	{

	@Override
	public Component getListCellRendererComponent(JList source, Object obj, int index, boolean selected, boolean focus)
		{
		Room r = null;
		JLabel label;
		if (obj==null)
			label = new JLabel("NULL");
		else
			{
			r = (Room)obj;
			label = new JLabel(r.roomName+"("+r.roomSize+")");
			label.setOpaque(true);
			}
		if (selected)
			{
			if(focus)
				{
				label.setBackground(new Color(0,0,128));
				label.setForeground(new Color(255,255,255));
				}
			else
				label.setBackground(new Color(192,192,192));
			}
		if(obj!=null)
			{
			if(!r.isFree)
				label.setForeground(new Color(255,0,0));
			}
		return label;
		}

	}
